package com.cdc.youthbanner.ui;

import android.os.Bundle;
import android.view.LayoutInflater;

import androidx.appcompat.app.AppCompatActivity;

import com.cdc.youthbanner.R;
import com.cdc.youthbanner.adapter.ImageAdapter;
import com.cdc.youthbanner.adapter.ImageTitleAdapter;
import com.cdc.youthbanner.bean.DataBean;
import com.cdc.youthbanner.databinding.ActivityConstraintLayoutBannerBinding;
import com.youth.banner.Banner;
import com.youth.banner.config.BannerConfig;
import com.youth.banner.config.IndicatorConfig;
import com.youth.banner.indicator.CircleIndicator;
import com.youth.banner.util.BannerUtils;

public class ConstraintLayoutBannerActivity extends AppCompatActivity {
    private static final String TAG = "banner_log";
    private ActivityConstraintLayoutBannerBinding mBinding;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        mBinding=ActivityConstraintLayoutBannerBinding.inflate(LayoutInflater.from(this));
        setContentView(mBinding.getRoot());
//        mBinding.banner.setAdapter(new ImageAdapter(DataBean.getTestData()));
//        mBinding.banner.setIndicator(new CircleIndicator(this));
//        mBinding.banner.isAutoLoop(false);

        mBinding.banner.setAdapter(new ImageTitleAdapter(DataBean.getTestData()));
        mBinding.banner.setIndicator(new CircleIndicator(this));
        mBinding.banner.setIndicatorSelectedColorRes(R.color.main_color);
        mBinding.banner.setIndicatorGravity(IndicatorConfig.Direction.RIGHT);
        mBinding.banner.setIndicatorMargins(new IndicatorConfig.Margins(0, 0,
                BannerConfig.INDICATOR_MARGIN, (int) BannerUtils.dp2px(12)));
        mBinding.banner.addBannerLifecycleObserver(this);
    }

    @Override
    protected void onStart() {
        super.onStart();
        mBinding.banner.start();
    }

    @Override
    protected void onStop() {
        super.onStop();
        mBinding.banner.stop();
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        mBinding.banner.destroy();
    }
}
